package com.secf.service.action.hpy.hys.ListDir;

import java.util.Arrays;

/**
 * @Author ms
 * @Date 2024-07-31 11:26
 */
public class Test7 {

    public static void main(String[] args) {
        int[] originalArray = {1, 2, 3, 4, 5};

        // 手动拷贝数组
        int[] manualCopy = new int[originalArray.length];
        for (int i = 0; i < originalArray.length; i++) {
            manualCopy[i] = originalArray[i];
        }
        System.out.println("手动拷贝: " + Arrays.toString(manualCopy));

        // 使用System.arraycopy拷贝数组
        int[] arrayCopy = new int[originalArray.length];
        System.arraycopy(originalArray, 0, arrayCopy, 0, originalArray.length);
        System.out.println("System.arraycopy拷贝: " + Arrays.toString(arrayCopy));

        // 数组克隆
        int[] clonedArray = originalArray.clone();
        System.out.println("数组克隆: " + Arrays.toString(clonedArray));
    }
}
